﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;

namespace ShopPowerTemplate.Common
{
    public class CryptoHelper
    {
        public static string HashString(string toHash)
        {
            IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(toHash, BinaryStringEncoding.Utf8);
            HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm("SHA1");
            IBuffer buffHash = objAlgProv.HashData(buffUtf8Msg);

            String strHashBase64 = CryptographicBuffer.EncodeToBase64String(buffHash);

            return strHashBase64;
        }
    }
}
